﻿using ChloeTest.DB;
using ChloeTest.Domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ChloeTest.Service
{
    public class UserService : IUserService
    {
        MYSQLDbContext _context;
        public UserService(MYSQLDbContext context)
        {
            _context = context;
        }
        public User FindUser()
        {
            var user = _context.Query<User>().Where(p => p.Name == "xxx").FirstOrDefault();
            return user;
        }

        public void Add()
        {
            var user = new User { Name="aa",Password="bb" };

            _context.Insert<User>(user);
        }

        public IList<User> GetList()
        {
            return _context.Query<User>().OrderBy(p=>p.Id).Take(50).ToList();
        }
    }
}
